import { PureComponent } from 'react';
import moment from 'moment';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
    Modal,
    DatePicker
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select;


@Form.create()
class CreateForm extends PureComponent {
	
	constructor(props) {
	    super(props);
	    this.state = {
	    	
	    }
	}
 

	okHandle = () => {
		const { form,handleAddByEdu } = this.props;

	    form.validateFields((err, fieldsValue) => {
		        if (err) return;
		        form.resetFields();
			   	if(fieldsValue.educational_experience_start_time) {
	      			fieldsValue.educational_experience_start_time = moment(fieldsValue.educational_experience_start_time._d).format("YYYY-MM-DD");
	      		}
				if(fieldsValue.educational_experience_end_time) {
	      			fieldsValue.educational_experience_end_time = moment(fieldsValue.educational_experience_end_time._d).format("YYYY-MM-DD");
	      		}
			    handleAddByEdu(fieldsValue);
		});
	};
	
	
	resetButton = () => {

	};

  render() {
    const {form: {getFieldDecorator}, modalVisibleByEdu,handleModalVisibleByEdu} = this.props;

return (
    <Modal
width={800}
destroyOnClose
title="添加教育经历"
visible={modalVisibleByEdu}
onOk={this.okHandle}
onCancel={() => handleModalVisibleByEdu()}
afterClose={() => this.resetButton()}
>
<Form  layout="vertical">
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
			
	        <Col  md={12} sm={24}>
		        <FormItem  label="毕业院校">
		            {getFieldDecorator('graduation_school', {
		            rules: [{ required: true, message: '请输入1-40位字符的院校名称', max: 40}],
		            })(<Input placeholder="1-40位字符" />)}
		        </FormItem>
	        </Col>
	        <Col  md={12} sm={24}>
		        <FormItem  label="专业">
		            {getFieldDecorator('major', {
		            rules: [{ required: true, message: '请输入1-40位字符的专业名称', max: 40}],
		            })(<Input placeholder="1-40位字符" />)}
		        </FormItem>
	        </Col>
		
		</Row>
    	<Row gutter={{ md: 8, lg: 24, xl: 48 }}>
	        <Col md={12} sm={24}>
	          <FormItem  label="学历">
	              {getFieldDecorator('education',{
	              	rules: [{ required: true,message: '请选择学历' }],
	              })(
	              	<Select placeholder="请选择" style={{ width: '100%' }}>
	                    <Select.Option key="81">小学</Select.Option>
	                    <Select.Option key="71">初中</Select.Option>
	                    <Select.Option key="61">高中</Select.Option>
	                    <Select.Option key="41">中专</Select.Option>
	                    <Select.Option key="21">本科</Select.Option>
	                    <Select.Option key="12">硕士</Select.Option>
	                    <Select.Option key="11">博士</Select.Option>
	                </Select>
	              )}
	          </FormItem>
	        </Col>
	        <Col md={12} sm={24}>
	          <FormItem  label="教学方式">
	              {getFieldDecorator('teaching_methods')(
	              	<Select placeholder="请选择" style={{ width: '100%' }}>
	                    <Select.Option key="81">统招全日制</Select.Option>
	                    <Select.Option key="71">自考</Select.Option>
	                    <Select.Option key="61">成考</Select.Option>
	                    <Select.Option key="41">其它</Select.Option>
	                </Select>
	              )}
	          </FormItem>
	        </Col>

    	</Row>
    	<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
	          <FormItem  label="入学时间">
	              {getFieldDecorator('educational_experience_start_time')(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
	          </FormItem>
	        </Col>
		    <Col md={12} sm={24}>
	          <FormItem  label="毕业时间">
	              {getFieldDecorator('educational_experience_end_time')(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
	          </FormItem>
	        </Col>

    	</Row>
    	{/*<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

	        <Col md={12} sm={24}>
	          <FormItem  label="是否第一学历">
	              {getFieldDecorator('first_education_type',{
	              	rules: [{ required: true,message: '请选择' }],
	              })(
	              	<Select placeholder="请选择" style={{ width: '100%' }}>
	                    <Select.Option key="1">是</Select.Option>
	                    <Select.Option key="0">否</Select.Option>
	                </Select>
	              )}
	          </FormItem>
	        </Col>

    	</Row>*/}

</Form>
</Modal>
);
  }

}

export default CreateForm;
